﻿using System;
using System.Collections.Generic;

namespace MyLib.Data {
	/// <summary>
	/// FulltextIndexTable
	/// </summary>
	[System.ComponentModel.DesignerCategory("Code")]
	public class FulltextIndexTable : System.Data.DataTable, System.Collections.Generic.IList<FulltextIndexRow> {
		/// <summary>
		/// 
		/// </summary>
		public const int ColumnSourceType = 0;

		/// <summary>
		/// 
		/// </summary>
		public const int ColumnSourceId = 1;

		/// <summary>
		/// 
		/// </summary>
		public const int ColumnSourceSubId = 2;

		/// <summary>
		/// 
		/// </summary>
		public const int ColumnTitle = 3;

		/// <summary>
		/// 
		/// </summary>
		public const int ColumnContent = 4;

		/// <summary>
		/// 
		/// </summary>
		public const int ColumnScore = 5;

		/// <summary>
		/// 
		/// </summary>
		public const int ColumnWeight = 6;

		/// <summary>
		/// 
		/// </summary>
		public const int ColumnDescription = 7;

		/// <summary>
		/// Create a new instance of FulltextIndexTable.
		/// </summary>
		protected override System.Data.DataTable CreateInstance() {
			return new FulltextIndexTable();
		}

		/// <summary>
		/// Create as new instance of FulltextIndexRow.
		/// </summary>
		/// <param name="builder">Builder for data row.</param>
		protected override System.Data.DataRow NewRowFromBuilder(System.Data.DataRowBuilder builder) {
			return new FulltextIndexRow(builder);
		}

		/// <summary>
		/// Count of rows.
		/// </summary>
		public int Count {
			get {
				return base.Rows.Count;
			}
		}

		/// <summary>
		/// Get row.
		/// </summary>
		/// <param name="index">Index of row.</param>
		public FulltextIndexRow this[int index] {
			get {
				return (FulltextIndexRow)(base.Rows[index]);
			}
			set {
				throw new System.NotImplementedException();
			}
		}

		/// <summary>
		/// Add a row.
		/// </summary>
		/// <param name="row" >Row which will be added.</param>
		public void AddRow(FulltextIndexRow row) {
			base.Rows.Add(row);
		}

		/// <summary>
		/// Remove a row.
		/// </summary>
		/// <param name="row" >Row which will be removed.</param>
		public void RemoveRow(FulltextIndexRow row) {
			base.Rows.Remove(row);
		}

		/// <summary>
		/// Add a new row with default values.
		/// </summary>
		public FulltextIndexRow AddNewRow() {
			var row = base.NewRow() as FulltextIndexRow;

			System.Diagnostics.Debug.Assert(row != null);

			base.Rows.Add(row);

			return row;
		}

		/// <summary>
		/// Type of data row.
		/// </summary>
		protected override System.Type GetRowType() {
			return typeof(FulltextIndexRow);
		}

		#region Members of System.Collections.Generic.IEnumerable<FulltextIndexRow>.

		/// <summary>
		/// 
		/// </summary>
		/// <param name="item"></param>
		/// <returns></returns>
		public int IndexOf(FulltextIndexRow item) {
			return base.Rows.IndexOf(item);
		}

		/// <summary>
		///
		/// </summary>
		/// <param name="index" ></param>
		/// <param name="item" ></param>
		public void Insert(int index, FulltextIndexRow item) {
			base.Rows.InsertAt(item, index);
		}

		/// <summary>
		///
		/// </summary>
		/// <param name="index"></param>
		public void RemoveAt(int index) {
			base.Rows.RemoveAt(index);
		}

		/// <summary>
		///
		/// </summary>
		/// <param name="item" ></param>
		public void Add(FulltextIndexRow item) {
			base.Rows.Add(item);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="item" ></param>
		/// <returns></returns>
		bool System.Collections.Generic.ICollection<FulltextIndexRow>.Contains(FulltextIndexRow item) {
			throw new System.NotImplementedException();
		}

		/// <summary>
		///
		/// </summary>
		/// <param name="keys" ></param>
		/// <returns></returns>
		public bool ContainsKey(params object[] keys) {
			System.Diagnostics.Debug.Assert(keys != null);
			System.Diagnostics.Debug.Assert(keys.Length != 0);

			return base.Rows.Contains(keys);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="array" ></param>
		/// <param name="arrayIndex" ></param>
		public void CopyTo(FulltextIndexRow[] array, int arrayIndex) {
			base.Rows.CopyTo(array, arrayIndex);
		}

		/// <summary>
		/// 
		/// </summary>
		public bool IsReadOnly {
			get {
				return false;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="item" ></param>
		/// <returns></returns>
		public bool Remove(FulltextIndexRow item) {
			base.Rows.Remove(item);
			return true;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <returns ></returns>
		public IEnumerator<FulltextIndexRow> GetEnumerator() {
			var iter = base.Rows.GetEnumerator();
			while (iter.MoveNext()) {
				yield return iter.Current as FulltextIndexRow;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <returns ></returns>
		System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
			return base.Rows.GetEnumerator();
		}

		#endregion

		/// <summary>
		/// Initialize data table.
		/// </summary>
		public FulltextIndexTable() {
			this.TableName = "FulltextIndexTable";
			this.BeginInit();
			var column0 = new System.Data.DataColumn("sourceType", typeof(int), null, System.Data.MappingType.Attribute);
			column0.DefaultValue = 0;
			base.Columns.Add(column0);
			var column1 = new System.Data.DataColumn("sourceId", typeof(string), null, System.Data.MappingType.Attribute);
			column1.DefaultValue = "";
			base.Columns.Add(column1);
			var column2 = new System.Data.DataColumn("sourceSubId", typeof(string), null, System.Data.MappingType.Attribute);
			column2.DefaultValue = "";
			base.Columns.Add(column2);
			var column3 = new System.Data.DataColumn("title", typeof(string), null, System.Data.MappingType.Attribute);
			column3.DefaultValue = "";
			base.Columns.Add(column3);
			var column4 = new System.Data.DataColumn("content", typeof(string), null, System.Data.MappingType.Attribute);
			column4.DefaultValue = "";
			base.Columns.Add(column4);
			var column5 = new System.Data.DataColumn("score", typeof(int), null, System.Data.MappingType.Attribute);
			column5.DefaultValue = 0;
			base.Columns.Add(column5);
			var column6 = new System.Data.DataColumn("weight", typeof(int), null, System.Data.MappingType.Attribute);
			column6.DefaultValue = 0;
			base.Columns.Add(column6);
			var column7 = new System.Data.DataColumn("description", typeof(string), null, System.Data.MappingType.Attribute);
			column7.DefaultValue = "";
			base.Columns.Add(column7);
			base.PrimaryKey = new System.Data.DataColumn[] 
            { 
                column0, column1, column2
            };
			this.EndInit();
		}
	} // end of FulltextIndexTable.

	/// <summary>
	/// FulltextIndexRow.
	/// </summary>
	[System.ComponentModel.DesignerCategory("Code")]
	public class FulltextIndexRow : System.Data.DataRow {
		/// <summary>
		/// Initialize data row.
		/// </summary>
		public FulltextIndexRow(System.Data.DataRowBuilder builder)
			: base(builder) {
		}

		/// <summary>
		/// 
		/// </summary>
		public string SourceId {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnSourceId];

				if (base.IsNull(col)) {
					throw new System.NullReferenceException("Value of FulltextIndexTable[\"sourceId\"] is null!");
				} else {
					return (string)(base[col]);
				}
			}
			set {
				var col = base.Table.Columns[FulltextIndexTable.ColumnSourceId];

				base[col] = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public void SetSourceIdNull() {
			var col = base.Table.Columns[FulltextIndexTable.ColumnSourceId];

			base[col] = System.Convert.DBNull;
		}

		/// <summary>
		/// 
		/// </summary>
		public bool IsSourceIdNull {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnSourceId];

				return base.IsNull(col);
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string SourceSubId {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnSourceSubId];

				if (base.IsNull(col)) {
					throw new System.NullReferenceException("Value of FulltextIndexTable[\"sourceSubId\"] is null!");
				} else {
					return (string)(base[col]);
				}
			}
			set {
				var col = base.Table.Columns[FulltextIndexTable.ColumnSourceSubId];

				base[col] = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public void SetSourceSubIdNull() {
			var col = base.Table.Columns[FulltextIndexTable.ColumnSourceSubId];

			base[col] = System.Convert.DBNull;
		}

		/// <summary>
		/// 
		/// </summary>
		public bool IsSourceSubIdNull {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnSourceSubId];

				return base.IsNull(col);
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string Title {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnTitle];

				if (base.IsNull(col)) {
					throw new System.NullReferenceException("Value of FulltextIndexTable[\"title\"] is null!");
				} else {
					return (string)(base[col]);
				}
			}
			set {
				var col = base.Table.Columns[FulltextIndexTable.ColumnTitle];

				base[col] = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public void SetTitleNull() {
			var col = base.Table.Columns[FulltextIndexTable.ColumnTitle];

			base[col] = System.Convert.DBNull;
		}

		/// <summary>
		/// 
		/// </summary>
		public bool IsTitleNull {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnTitle];

				return base.IsNull(col);
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string Content {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnContent];

				if (base.IsNull(col)) {
					throw new System.NullReferenceException("Value of FulltextIndexTable[\"content\"] is null!");
				} else {
					return (string)(base[col]);
				}
			}
			set {
				var col = base.Table.Columns[FulltextIndexTable.ColumnContent];

				base[col] = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public void SetContentNull() {
			var col = base.Table.Columns[FulltextIndexTable.ColumnContent];

			base[col] = System.Convert.DBNull;
		}

		/// <summary>
		/// 
		/// </summary>
		public bool IsContentNull {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnContent];

				return base.IsNull(col);
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public int SourceType {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnSourceType];

				if (base.IsNull(col)) {
					throw new System.NullReferenceException("Value of FulltextIndexTable[\"sourceType\"] is null!");
				} else {
					return (int)(base[col]);
				}
			}
			set {
				var col = base.Table.Columns[FulltextIndexTable.ColumnSourceType];

				base[col] = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public void SetSourceTypeNull() {
			var col = base.Table.Columns[FulltextIndexTable.ColumnSourceType];

			base[col] = System.Convert.DBNull;
		}

		/// <summary>
		/// 
		/// </summary>
		public bool IsSourceTypeNull {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnSourceType];

				return base.IsNull(col);
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public int Score {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnScore];

				if (base.IsNull(col)) {
					throw new System.NullReferenceException("Value of FulltextIndexTable[\"score\"] is null!");
				} else {
					return (int)(base[col]);
				}
			}
			set {
				var col = base.Table.Columns[FulltextIndexTable.ColumnScore];

				base[col] = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public void SetScoreNull() {
			var col = base.Table.Columns[FulltextIndexTable.ColumnScore];

			base[col] = System.Convert.DBNull;
		}

		/// <summary>
		/// 
		/// </summary>
		public bool IsScoreNull {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnScore];

				return base.IsNull(col);
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public int Weight {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnWeight];

				if (base.IsNull(col)) {
					throw new System.NullReferenceException("Value of FulltextIndexTable[\"weight\"] is null!");
				} else {
					return (int)(base[col]);
				}
			}
			set {
				var col = base.Table.Columns[FulltextIndexTable.ColumnWeight];

				base[col] = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public void SetWeightNull() {
			var col = base.Table.Columns[FulltextIndexTable.ColumnWeight];

			base[col] = System.Convert.DBNull;
		}

		/// <summary>
		/// 
		/// </summary>
		public bool IsWeightNull {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnWeight];

				return base.IsNull(col);
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string Description {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnDescription];

				if (base.IsNull(col)) {
					throw new System.NullReferenceException("Value of FulltextIndexTable[\"description\"] is null!");
				} else {
					return (string)(base[col]);
				}
			}
			set {
				var col = base.Table.Columns[FulltextIndexTable.ColumnDescription];

				base[col] = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public void SetDescriptionNull() {
			var col = base.Table.Columns[FulltextIndexTable.ColumnDescription];

			base[col] = System.Convert.DBNull;
		}

		/// <summary>
		/// 
		/// </summary>
		public bool IsDescriptionNull {
			get {
				var col = base.Table.Columns[FulltextIndexTable.ColumnDescription];

				return base.IsNull(col);
			}
		}
	} // end of FulltextIndexRow.
}
